﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration.Conventions;
using zichan.Entity;
using System.Data.Entity.Migrations;

namespace zichan.DAL
{
    public class ZichanDBContext : DbContext
    {
        public ZichanDBContext():base("name=ZichanDBContext")
        {
            //Database.SetInitializer<ZichanDBContext>(new CreateDatabaseIfNotExists<ZichanDBContext>());
            //自动创建表，如果Entity有改到就更新到表结构
            Database.SetInitializer<ZichanDBContext>(new MigrateDatabaseToLatestVersion<ZichanDBContext,Migrations.Configuration>());
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
        public DbSet<AsseteClassify> AsseteClassifies { get; set; }
        public DbSet<Asset> Assets { get; set; }
        public DbSet<AsseteField> AsseteFields { get; set; }
        public DbSet<AssetTemp> AssetTemps { get; set; }
        public DbSet<AsssetLog> AsssetLogs { get; set; }
        public DbSet<Cabinet> Cabinets { get; set; }
        public DbSet<CabinetClass> CabinetClasses { get; set; }
        public DbSet<ClassLog> ClassLogs { get; set; }
        public DbSet<CompanyClass> CompanyClasses { get; set; }
        public DbSet<IP> IPs { get; set; }
        public DbSet<MachineRoom> MachineRooms { get; set; }
        public DbSet<MachineRoomClass> MachineRoomClasses { get; set; }
        public DbSet<MachineRoomLog> MachineRoomLogs { get; set; }
        public DbSet<PutawayServer> PutawayServers { get;set; }
        public DbSet<ServerInfo> ServerInfos { get; set; }
        public DbSet<UsageLog> UsageLogs { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Staff> Staffs { get; set; }
        public DbSet<StaffRole> StaffRoles { get; set; }
        public DbSet<Menu> Menus { get; set; }
        public DbSet<ConsumateInfo> ConsumateInfos { get; set; }
        public DbSet<CabinetUseLog> CabinetUseLoges{ get; set; }
        public DbSet<DepartmentRole> DepartmentRoles { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<ServerPurposeClass> ServerPurposeClasses { get; set; }
        public DbSet<ServerPurposeSubClass> ServerPurposeSubClasses { get; set; }
    }
}
